package net.recursv.motific.atweaver

import net.recursv.motific.atweaver.FileParser

/**
 * Created by: recursv
 * Date: 13/08/2009
 * Time: 4:56:24 PM
 */

public class AtWeaver {
  public static void main(String[] args) {

    FileParser parser = new FileParser()

    args.each {
      if (it.startsWith("-in="))
        parser.input.add(new File(it.substring("-in=".length()).replace("\"", ""))) 
      else if (it.startsWith("-out="))
        parser.output = it.substring("-out=".length()).replace("\"", "")
      else if (it.startsWith("-overwrite="))
          parser.overwrite = Boolean.parseBoolean(it.substring("-overwrite=".length()))
        else if (it.startsWith("-cleanOutput="))
            parser.overwrite = Boolean.parseBoolean(it.substring("-cleanOutput=".length()))
        else if (it.startsWith("-verbose="))
            parser.verbose = Boolean.parseBoolean(it.substring("-verbose=".length()))
    }

    if (parser.validate())
      parser.run();
    else
      printInstructions()
  }

  static def printInstructions() {
    println "FileParser -in=<input dir> -out=<output dir> [-overwrite=<true|false>] [-cleanOutput=<true|false>] [-verbose=<true|false>] "
  }
}
